package com.zfy.cmsservice.controller;


import com.zfy.cmsservice.entity.subject.OneSubject;
import com.zfy.cmsservice.service.SubjectsService;
import com.zfy.commonutils.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * <p>
 * 科目表 前端控制器
 * </p>
 *
 * @author testjava
 * @since 2023-11-06
 */
@RestController
@RequestMapping("/cmsservice/subject")
@Api(description = "课程分类管理-课程分类信息维护")
public class SubjectsController {
    @Autowired
    private SubjectsService subjectsService;

    //添加课程分类 获取上传过来的文件
    @ApiOperation(value = "添加课程分类(科目)")
    @PostMapping("addSubject")
    public R addSubject(MultipartFile file){
        subjectsService.saveSubject(file,subjectsService);
        return R.ok();
    }

    //课程分类列表 树形
    @ApiOperation(value = "课程分类列表")
    @GetMapping("getAllSubject")
    public R getAllSubject(){
        //list 泛型一级分类
        List<OneSubject> list =  subjectsService.getAllOneTwoSubject();
        return R.ok().data("list",list);
    }

}

